package com.hzw.rest;


import com.hzw.api.IUserService;
import com.hzw.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.hzw.common.PageResult;

import java.util.List;


@Controller
@CrossOrigin
@RequestMapping("showUserList")
public class UserController {

    @Autowired
    IUserService userService;

    /**
     * .
     * 查询全部用户
     *
     * @return
     */
    @PostMapping("pageSelect")
    @ResponseBody
    public PageResult<User> pageSelect(@RequestBody User user) {
        return userService.pageSelect(user);
    }

    /**
     * .
     * 通过Id查询（回显功能功能）
     *
     * @return
     */
    @PostMapping("selectById")
    @ResponseBody
    public User selectById(@RequestBody User user) {
        return userService.selectById(user);
    }

    /**
     * 查询用户
     *
     * @return
     */
    @PostMapping("select")
    @ResponseBody
    public List<User> select(@RequestBody User user) {
        return userService.select(user);
    }

    /**
     * 更新用户信息
     * @param user
     */
    @PostMapping("update")
    @ResponseBody
    public void update(@RequestBody User user) {
       userService.updateById(user);
    }

    /**
     * 删除用户
     * @param user
     */
    @PostMapping("delete")
    @ResponseBody
    public void delById(@RequestBody User user) {
        userService.delById(user);
    }

}
